var Logger = (function () {

    let traceStyle = "color:white;";
    let debugStyle = "color:gray;";
    let informationStyle = "color:green;";
    let warningStyle = "color:yellow;";
    let errorStyle = "color:red;";
    let criticalStyle = "color:darkred;";
    let styles = new Map([
        [1, traceStyle],
        [2, debugStyle],
        [3, informationStyle],
        [4, warningStyle],
        [5, errorStyle],
        [6, criticalStyle],
    ]);

    let level = 0;


    function TimeStamp() {
        const date = new Date();
        return `${date.getFullYear()}${(date.getMonth() + 1).toString().padStart(2, '0')}${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}:${date.getMilliseconds().toString().padStart(3, '0')}`;
    }

    function Log(level, message) {
        if (level < level) {
            return;
        }
        console.log(`%c${TimeStamp()}\t${typeof message == 'object' ? JSON.stringify(message) : message}`, styles.get(level));
    }

    function SetLogLevel(level) {
        level = level;
        console.log(`%c${TimeStamp()}\t日志级别切换为:${level}`, styles.get(3));
    }

    function LogTrace(message) {
        Log(1, message);
    }

    function LogDebug(message) {
        Log(2, message);
    }

    function LogInformation(message) {
        Log(3, message);
    }

    function LogWarning(message) {
        Log(3, message);
    }

    function LogError(message) {
        Log(5, message);
    }

    function LogCritical(message) {
        Log(6, message);
    }

    return {
        SetLogLevel,
        LogTrace,
        LogDebug,
        LogInformation,
        LogWarning,
        LogError,
        LogCritical,
    };
})();